package com.jinbooks.enums;

import com.jinbooks.common.RemoteVersion;
import lombok.Getter;

import java.util.function.Function;

/**
 * Ceres 程序类型
 *
 * @author jiangzeyin
 * @since 2019/4/17
 */
@Getter
public enum Type {

    /**
     * 中心服务端
     */
    Server("com.jinbooks.CeresServerApplication", RemoteVersion::getServerUrl, "CERES_SERVER_APPLICATION"),
    ;

    private final Function<RemoteVersion, String> remoteUrl;
    private final String applicationClass;
    private final String tag;

    Type(String applicationClass, Function<RemoteVersion, String> remoteUrl, String tag) {
        this.applicationClass = applicationClass;
        this.remoteUrl = remoteUrl;
        this.tag = tag;
    }

    public String getRemoteUrl(RemoteVersion remoteVersion) {
        return remoteUrl.apply(remoteVersion);
    }
}